﻿'----------------------------------------------
'   
'   Kernel Info:---------------------------
'   Developer:              Joshua Teeter
'   Genesis:                09-06-03
'   Last Update:            09-06-04
'   Origional Version:      0.0.0.0
'   Current Version:        0.0.0.1
'   ---------------------------------------
'   
'   
'   If you modify this code please leave your name in the modified by list seperated by a comma. 
'   Changes are to be denoted in the following manner:
'                                                       * New
'                                                       ^ Updated
'                                                       - Removed
'                                                       + Added Functionality
'                                                       ! Bug unresolved
'                                                       / Bug resolved
'                                                       % Modified but not changed in a noticeable way in terms of functionality
'  
'  Please use the following as a template and copy and paste as a new comment for each modification.
'   
'   Modification Info:---------------------
'   Class Name:             Setting.vb
'   Modified by:            NULL
'   Last Update:            NULL
'   Current Version:        #.#.#.#
'   Changes:                 NULL
'   ---------------------------------------
'

Public Class Theme

    '
    ' Label back colours
    '
    Private lblBRed As Integer = My.MySettings.Default.lblBRedColor
    Private lblBGre As Integer = My.MySettings.Default.lblBGreColor
    Private lblBBlu As Integer = My.MySettings.Default.lblBBluColor

    '
    ' Label fore colours
    '
    Private lblFRed As Integer = My.MySettings.Default.lblFRedColor
    Private lblFGre As Integer = My.MySettings.Default.lblFGreColor
    Private lblFBlu As Integer = My.MySettings.Default.lblFBluColor

    '
    ' Listbox back colours
    '
    Private lbBRed As Integer = My.MySettings.Default.lbBRedColor
    Private lbBGre As Integer = My.MySettings.Default.lbBGreColor
    Private lbBBlu As Integer = My.MySettings.Default.lbBBluColor

    '
    ' Listbox fore colours
    '
    Private lbFRed As Integer = My.MySettings.Default.lbFRedColor
    Private lbFGre As Integer = My.MySettings.Default.lbFGreColor
    Private lbFBlu As Integer = My.MySettings.Default.lbFBluColor

    '
    ' Form back colours
    '
    Private frmBRed As Integer = My.MySettings.Default.frmBRedColor
    Private frmBGre As Integer = My.MySettings.Default.frmBGreColor
    Private frmBBlu As Integer = My.MySettings.Default.frmBBluColor

    '
    ' Form fore colours
    '
    Private frmFRed As Integer = My.MySettings.Default.frmFRedColor
    Private frmFGre As Integer = My.MySettings.Default.frmFGreColor
    Private frmFBlu As Integer = My.MySettings.Default.frmFBluColor

    '
    ' Button back colours
    '
    Private btnBRed As Integer = My.MySettings.Default.btnBRedColor
    Private btnBGre As Integer = My.MySettings.Default.btnBGreColor
    Private btnBBlu As Integer = My.MySettings.Default.btnBBluColor

    '
    ' Button mouse over colours
    '
    Private btnMOBRed As Integer = My.MySettings.Default.btnMOBRed
    Private btnMOBGre As Integer = My.MySettings.Default.btnMOBGre
    Private btnMOBBlu As Integer = My.MySettings.Default.btnMOBBlu

    '
    ' Button mouse click colours
    '
    Private btnMDBRed As Integer = My.MySettings.Default.btnMDBRed
    Private btnMDBGre As Integer = My.MySettings.Default.btnMDBGre
    Private btnMDBBlu As Integer = My.MySettings.Default.btnMDBBlu


    '
    ' Button fore colours
    '
    Private btnFRed As Integer = My.MySettings.Default.btnFRedColor
    Private btnFGre As Integer = My.MySettings.Default.btnFGreColor
    Private btnFBlu As Integer = My.MySettings.Default.btnFBluColor

    '
    ' Title fore colours
    '
    Private lblSpecialR As Integer = My.MySettings.Default.lblSpecialR
    Private lblSpecialG As Integer = My.MySettings.Default.lblSpecialG
    Private lblSpecialB As Integer = My.MySettings.Default.lblSpecialB

    '
    ' Opacity
    '
    Private transparent As Integer = My.MySettings.Default.transparent

    '
    ' Dictionary to hold the information
    '
    Private colors As New Dictionary(Of String, Integer)

    '
    ' Lets the forms get the colour information
    '
    Public ReadOnly Property _colours() As Dictionary(Of String, Integer)
        Get
            Return colors
        End Get
    End Property

    '
    ' Adds the [default] values to the dictionary.
    '
    Public Sub New()
        colors.Clear()

        With colors

            .Add("lblBRed", lblBRed)
            .Add("lblBGre", lblBGre)
            .Add("lblBBlu", lblBBlu)

            .Add("lblFRed", lblFRed)
            .Add("lblFGre", lblFGre)
            .Add("lblFBlu", lblFBlu)

            .Add("lbBRed", lbBRed)
            .Add("lbBGre", lbBGre)
            .Add("lbBBlu", lbBBlu)

            .Add("lbFRed", lbFRed)
            .Add("lbFGre", lbFGre)
            .Add("lbFBlu", lbFBlu)

            .Add("frmBRed", frmBRed)
            .Add("frmBGre", frmBGre)
            .Add("frmBBlu", frmBBlu)

            .Add("frmFRed", frmFRed)
            .Add("frmFGre", frmFGre)
            .Add("frmFBlu", frmFBlu)

            .Add("btnBRed", btnBRed)
            .Add("btnBGre", btnBGre)
            .Add("btnBBlu", btnBBlu)

            .Add("btnFRed", btnFRed)
            .Add("btnFGre", btnFGre)
            .Add("btnFBlu", btnFBlu)

            .Add("btnMOBRed", btnMOBRed)
            .Add("btnMOBGre", btnMOBGre)
            .Add("btnMOBBlu", btnMOBBlu)

            .Add("btnMDBRed", btnMDBRed)
            .Add("btnMDBGre", btnMDBGre)
            .Add("btnMDBBlu", btnMDBBlu)

            .Add("lblSpecialR", lblSpecialR)
            .Add("lblSpecialG", lblSpecialG)
            .Add("lblSpecialB", lblSpecialB)

            .Add("Transparent", transparent)

        End With
        MemoryManagement.FlushMemory()
    End Sub

    '
    ' Loads a skin from a file
    '
    Protected Friend Sub OpenSettings(ByRef fileName As String)

        My.Settings.SkinPath = fileName
        My.Settings.Save()

        Try
            '
            ' See if the file exists 
            '
            If System.IO.File.Exists(fileName) Then

                '
                ' Initialize the counter 
                '
                Dim count As Integer = 0
                Dim keys() As String = colors.Keys.ToArray


                ' Set the streamreader, the line to be read, and the array of split line contents
                Dim input As System.IO.StreamReader = System.IO.File.OpenText(fileName)
                Dim line As String = ""
                Dim lineSplit() As String

                ' Run trough the file and dump the information into an array, 
                ' which is re sized according to what is needed.
                While input.Peek <> -1


                    ' Read an actual line
                    line = input.ReadLine()

                    ' If the line does not contain nothing then we proceed
                    If (line <> "") And (line.StartsWith(">"c) = False) And (line.StartsWith(" "c) = False) Then

                        lineSplit = line.Split("|"c)

                        If lineSplit.Count = 2 And count < keys.Count Then
                            Try
                                colors(keys(count)) = CInt(lineSplit(1))
                            Catch a As InvalidCastException
                                MsgBox("Line: " & count & " has incorrect values!", MsgBoxStyle.Critical, "ERROR!")
                            End Try

                            count += 1

                        Else
                            count += 1


                        End If


                    End If

                End While

                ' Close the file (*NOTE* This is required)

                input.Close()
            End If
        Catch e1 As Exception
            MsgBox(e1.Message, MsgBoxStyle.Critical, "Handled file exception")
        End Try

        Me.Finalize()
        MemoryManagement.FlushMemory()
    End Sub

End Class
